﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Forum.aspx.cs" Inherits="Forum" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="col-md-8 col-md-offset-2">
        <h1>FORUM </h1>


        <asp:LinkButton runat="server" ID="createTopicButton" PostBackUrl="~/CreateTopic.aspx"> Create Topic </asp:LinkButton>


        <asp:ListView ID="ListView1" runat="server" DataSourceID="ObjectDataSource1" DataKeyNames="TopicID" OnItemDeleted="ListView1_ItemDeleted">
            <AlternatingItemTemplate>
                <li style="">
                    Date:
                <asp:Label Text='<%# Eval("Date") %>' runat="server" ID="DateLabel" /><br />
                    Header:
                <asp:HyperLink ID="headerHyperlink" runat="server" NavigateUrl='<%# Eval("TopicID", "~/Topic.aspx?topic={0}") %>'>
                    <asp:Label Text='<%# Eval("Header") %>' runat="server" ID="HeaderLabel" /><br />
                </asp:HyperLink><asp:Button runat="server" CommandName="Delete" Text="Delete" ID="DeleteButton" />
                </li>

            </AlternatingItemTemplate>
            <EmptyDataTemplate>
                No topics posted.
            </EmptyDataTemplate>
            <ItemSeparatorTemplate>
                <br />
            </ItemSeparatorTemplate>
            <ItemTemplate>
                <li style="">
                    Date:
                    <asp:Label Text='<%# Eval("Date") %>' runat="server" ID="DateLabel" /><br />
                    Header:
                    <asp:HyperLink ID="headerHyperlink" runat="server" NavigateUrl='<%# Eval("TopicID", "~/Topic.aspx?topic={0}") %>'>
                        <asp:Label Text='<%# Eval("Header") %>' runat="server" ID="HeaderLabel" /><br />
                    </asp:HyperLink><asp:Button runat="server" CommandName="Delete" Text="Delete" ID="DeleteButton" Visible='<%#DeleteButtonVisible(Convert.ToInt32(Eval("UserID")))%>' />
                </li>

            </ItemTemplate>
            <LayoutTemplate>
                <ul runat="server" id="itemPlaceholderContainer" style="">
                    <li runat="server" id="itemPlaceholder" />
                </ul>
                <div style="">
                    <asp:DataPager runat="server" ID="DataPager1">
                        <Fields>
                            <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowLastPageButton="True"></asp:NextPreviousPagerField>
                        </Fields>
                    </asp:DataPager>

                </div>

            </LayoutTemplate>

            <SelectedItemTemplate>
                <li style="">TopicID:
                    <asp:Label Text='<%# Eval("TopicID") %>' runat="server" ID="TopicIDLabel" /><br />
                    UserID:
                    <asp:Label Text='<%# Eval("UserID") %>' runat="server" ID="UserIDLabel" /><br />
                    Date:
                    <asp:Label Text='<%# Eval("Date") %>' runat="server" ID="DateLabel" /><br />
                    Header:
                    <asp:Label Text='<%# Eval("Header") %>' runat="server" ID="HeaderLabel" /><br />
                    <asp:Button runat="server" CommandName="Delete" Text="Delete" ID="DeleteButton" />
                </li>
            </SelectedItemTemplate>
        </asp:ListView>

        <asp:ObjectDataSource runat="server" ID="ObjectDataSource1" SelectMethod="GetAllForumPosts" TypeName="Service" DeleteMethod="DeleteTopicOnID">
            <DeleteParameters>
                <asp:Parameter Name="TopicID" Type="Int32"></asp:Parameter>
            </DeleteParameters>
        </asp:ObjectDataSource>
    </div>
</asp:Content>

